import { createRouter, createWebHistory } from 'vue-router';
import MyHome from '../components/MyHome.vue';
import MyOther from '../components/MyOther.vue';
import MyLearn from '../components/MyLearn.vue';
import MyLearn2 from '../components/MyLearn2.vue';
import MyLearn3 from '../components/MyLearn3.vue';

const routes = [
	{
		path: '/',
		name: 'MyHome',
		component: MyHome
	},
	{
		path: '/other',
		name: 'MyOther',
		component: MyOther
	},
	{
		path: '/learn',
		name: 'MyLearn',
		component: MyLearn
	},
	{
		path: '/learn2',
		name: 'MyLearn2',
		component: MyLearn2
	},
	{
		path: '/learn3',
		name: 'MyLearn3',
		component: MyLearn3
	}
];

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes,
	linkActiveClass: 'router-link-active'
});

router.beforeEach((to, from, next) => {
	console.log('beforeEach');
	console.log(to);
	if (to.name !== 'MyLearn') {
		const btn = document.querySelector('#fullBtn')
		btn && document.body.removeChild(btn)
	}
	next();
});

export default router;
